export default {
  TOGGLE_SIDEBAR: (state) => {
    state.isfold = !state.isfold;
  },
  GETURL: (state, data) => {
    state.links = data.url;
    state.names = data.name;
    state.name = data.names;
  },
  ADD_VISITED_VIEWS: (state, view) => {
    if (state.visitedViews.some((v) => v.path === view.path)) return;
    state.visitedViews.push({
      name: view.name,
      path: view.path,
      title: view.meta.title || 'no-name'
    });
    if (!view.meta.noCache) {
      state.cachedViews.push(view.name);
    }
  },
  DEL_VISITED_VIEWS: (state, view) => {
    let index;
    for (const [i, e] of state.visitedViews.entries()) {
      if (e.path === view.path) {
        index = i;
        break;
      }
    }
    state.visitedViews.splice(index, 1);
  },
  //  判断是否是第一次进入
  CHANGELOADSTATE: (state) => {
    state.isFirstLoad = !state.isFirstLoad;
  },
  SHOWLOADING: (state) => {
    state.showLoading = true;
  },
  HIDELOADING: (state) => {
    state.showLoading = false;
  },
  switchLang: (state, lang) => {
    state.lang = lang;
    // this.lang = lang;
  },
  SET_LANGUAGE: (state, language) => {
    state.language = language;
    window.localStorage.setItem('language', language);
  },
  LOCAL: (state, data) => {
    state.local = data;
  },
  SPRINKLER: (state, data) => {
    state.sprinkler = data;
  }
};
